package com.imooc.bilibili.domain.core;

import lombok.Getter;
import lombok.Setter;

/**
 * @author gcq
 * @Create 2022-05-22
 */
@Getter
@Setter

public class JsonResponse<T> {
    private String code;
    private String message;
    private T data;

    public JsonResponse(String code, String message) {
        this.code = code;
        this.message = message;
    }
    public JsonResponse(T data) {
        this.code = "200";
        this.message = "成功";
        this.data = data;
    }
    public static JsonResponse<String> success() {
        return new JsonResponse<>(null);
    }
    public static JsonResponse<String> success(String data) {
        return new JsonResponse<>(data);
    }
    public static JsonResponse<String> fail() {
        return new JsonResponse<>("1", "失败");
    }
    public static JsonResponse<String> fail(String code, String message) {
        return new JsonResponse<>(code, message);
    }
}